﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="RefundLookup.ascx.cs" Inherits="WebUI.Controls.RefundLookup" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

<script type="text/javascript">
    var IMEILength = <%= WebUI.BasePage.SysVars.IMEILength %>;
    
    function txtIMEI_onchange(txt) {
        if(!isNumeric(txt.value)){
            alert("Invalid IMEI number!");
            txt.value = "";
            return;
        }
        
        if(txt.value.length >= IMEILength){
            document.getElementById("<%=btnAddIMEI.ClientID %>").click();
            txt.value='';
        }
    }       
    
    function isNumeric(value) {
        if (value != null && !value.toString().match(/^[-]?\d*\.?\d*$/)) return false;
            return true;
    }

    function focusIMEI(){
        document.getElementById('<%= txtIMEI.ClientID %>').focus();
    }
</script>

<asp:Panel ID="mainPanel" runat="server">
    <asp:Panel ID="imeiPanel" runat="server" DefaultButton="btnAddIMEI" onfocus="this.select();">
        <table width="100%">
            <tr>
                <td style="text-align:right; vertical-align:top;" >
                    <asp:Label ID="Label1" Text="Brand:" runat="server" class="labelMessage"></asp:Label>
                </td>
                <td style="text-align:left; vertical-align:top;" >
                    <asp:DropDownList Width="150px" AutoPostBack="true" ID="ddlBrand" runat="server" OnSelectedIndexChanged="ddlBrand_OnSelectedIndexChanged">
                    </asp:DropDownList>
                    <asp:RequiredFieldValidator ValidationGroup="AddRefund" Display="Dynamic" ID="RequiredFieldValidator3"
                        runat="server" ControlToValidate="ddlBrand" class="requiredField" Text="required"
                        ErrorMessage="required"></asp:RequiredFieldValidator>
                </td>
            </tr>
            <tr>
                 <td style="text-align:right; vertical-align:top;" >
                    <asp:Label class='labelMessage' ID="Label4" runat="server" Text="Model:"></asp:Label>
                </td>
                <td style="text-align:left; vertical-align:top;" >
                    <asp:DropDownList Width="180px" AutoPostBack="true" ID="ddlModel" runat="server">
                        <asp:ListItem Text="--Select--" Value=""></asp:ListItem>
                    </asp:DropDownList>
                    <asp:RequiredFieldValidator ValidationGroup="AddRefund" Display="Dynamic" ID="RequiredFieldValidator4"
                        runat="server" ControlToValidate="ddlModel" class="requiredField" Text="required"
                        ErrorMessage="required"></asp:RequiredFieldValidator>
                </td>
            </tr>
            <tr>
                <td style="text-align:right; vertical-align:top;" >
                    <asp:Label ID="Label2" Text="IMEI:" runat="server" class="labelMessage"></asp:Label>
                </td>
                <td style="text-align:left; vertical-align:top;" >
                    <asp:TextBox ID="txtIMEI" runat="server" Width="145px"></asp:TextBox>
                    <asp:RequiredFieldValidator Display="Dynamic" ValidationGroup="AddRefund" ID="RequiredFieldValidator2"
                        runat="server" ControlToValidate="txtIMEI" class="requiredField" Text="required"
                        ErrorMessage="required"></asp:RequiredFieldValidator>
                </td>
            </tr>
            <tr>
                <td style="text-align:right; vertical-align:top;" >
                    <asp:Label ID="Label3" Text="Price:" runat="server" class="labelMessage"></asp:Label>
                </td>
                <td style="text-align:left; vertical-align:top;" >
                    <asp:TextBox ID="txtPrice"  runat="server" Width="80px" >0</asp:TextBox>
                    <asp:RequiredFieldValidator Display="Dynamic" ValidationGroup="AddRefund" ID="RequiredFieldValidator1"
                        runat="server" ControlToValidate="txtPrice" class="requiredField" Text="required"
                        ErrorMessage="required"></asp:RequiredFieldValidator><br />
                    <cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender3" TargetControlID="txtPrice" FilterType="Numbers,Custom" ValidChars="." runat="server">
                    </cc1:FilteredTextBoxExtender>
                </td>
            </tr>
            <tr>
                <td style="text-align:right; vertical-align:top;" >
                   
                </td>
                <td style="text-align:left; vertical-align:top;" >  
                    <asp:Button ValidationGroup="AddRefund" ID="btnAddIMEI" Text="Add to Refund" runat="server" OnClick="btnAddIMEI_OnClick" />
                </td>
            </tr>
        </table>
        
    </asp:Panel>
</asp:Panel>